<template>
  <div class="container">
    <div class="selfInfo">
      <div class="leftImg">
        <img src="@/assets/组 5823@2x.png" alt="" />
      </div>
      <div class="rightBox">
        <div class="name">
          {{ userInfo.userName }}
        </div>
        <div class="labelBox">
          <div class="label greenColor">{{ userInfo.roleName }}</div>
          <div class="label">{{ userInfo.departmentName }}</div>
        </div>
      </div>
    </div>

    <div class="cardBox">
      <div class="cardItem">
        <div class="leftImg">
          <img src="@/assets/组 5833@2x.png" alt="" />
          <div>个人信息</div>
        </div>
        <div class="rightImg">
          <img src="@/assets/组 5411@2x.png" alt="" />
        </div>
      </div>
      <div class="cardItem" @click="loginOut">
        <div class="leftImg">
          <img src="@/assets/组 5837@2x.png" alt="" />
          <div>退出登录</div>
        </div>
        <div class="rightImg">
          <img src="@/assets/组 5411@2x.png" alt="" />
        </div>
      </div>
    </div>

    <tabbar :activeIndex.sync="nowActive"></tabbar>
  </div>
</template>

<script>
import { userInfoApi } from '@/api/index'
import tabbar from '@/components/tabbar'
export default {
  name: 'minePage',
  props: {},
  components: {
    tabbar,
  },
  data() {
    return {
      nowActive: 1,
      userInfo: {},
      isLoginMsg: {},
    }
  },
  created() {
    this.isLoginMsg = JSON.parse(sessionStorage.getItem('loginInfo'))
    if (!this.isLoginMsg) {
      this.loginOut()
    }
    this.getUserInfo()
  },
  methods: {
    loginOut() {
      sessionStorage.clear()
      this.$router.push('/login')
    },
    async getUserInfo() {
      const res = await userInfoApi({ id: this.isLoginMsg.userId })
      this.userInfo = res.data
    },
  },
  mounted() {},
  watch: {},
  computed: {},
  filters: {},
}
</script>

<style scoped lang="scss">
.container {
  height: 100vh;
  width: 100%;
  background: linear-gradient(180deg, #e6f8ee 0%, #fff 100%);
}
.selfInfo {
  display: flex;
  align-items: center;
  padding-top: 40px;
  padding-left: 28px;
  .leftImg {
    width: 72px;
    height: 72px;
    margin-right: 12px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .rightBox {
    .name {
      font-size: 16px;
      color: #2f3331;
      font-weight: bold;
    }
    .labelBox {
      display: flex;
      padding-top: 12px;
      .label {
        // width: 50px;
        height: 24px;
        background: #f5f7f6;
        border-radius: 12px;
        font-size: 12px;
        color: #616463;
        text-align: center;
        line-height: 24px;
        margin-right: 8px;
        padding: 2px 12px;
      }
      .greenColor {
        color: #fff;
        background: #009c5e;
      }
    }
  }
}
.cardBox {
  padding: 16px;
  .cardItem {
    background-color: #fff;
    height: 48px;
    // width: 100%;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    margin-top: 16px;
    .leftImg {
      display: flex;
      align-items: center;
      img {
        width: 24px;
        height: 24px;
        margin-right: 8px;
      }
    }
    .rightImg {
      img {
        width: 24px;
        height: 24px;
      }
    }
  }
}
</style>
